翻訳と辞書
Words near each other
・ Knute Buehler
・ Knute Cauldwell
・ Knute Heldner
・ Knute Hill
・ Knute hitch
・ Knute Nelson
・ Knute Nelson Memorial Park
・ Knute Rockne
・ Knute Rockne Bowl
・ Knute Rockne, All American
・ Knute Township, Polk County, Minnesota
・ Knutepunkt
・ Knuth
・ Knuth Prize
・ Knuth reward check
Knuth's Algorithm X
・ Knuth's Simpath algorithm
・ Knuth's up-arrow notation
・ Knuthenborg
・ Knuthenborg Safaripark
・ Knuth–Bendix completion algorithm
・ Knuth–Morris–Pratt algorithm
・ Knuts Skujenieks
・ Knutsdotter
・ Knutsen
・ Knutsen & Ludvigsen
・ Knutsen & Ludvigsens Beste
・ Knutsen & Ludvigsens Ver'ste'
・ Knutsen Lake
・ Knutsen NYK Offshore Tankers


Dictionary Lists
翻訳と辞書 辞書検索 [ 開発暫定版 ]
スポンサード リンク

Knuth's Algorithm X : ウィキペディア英語版
Knuth's Algorithm X
"Algorithm X" is the name Donald Knuth used in his paper "Dancing Links" to refer to "the most obvious trial-and-error approach" for finding all solutions to the exact cover problem.〔 Technically, Algorithm X is a recursive, nondeterministic, depth-first, backtracking algorithm. While Algorithm X is generally useful as a succinct explanation of how the exact cover problem may be solved, Knuth's intent in presenting it was merely to demonstrate the utility of the dancing links technique via an efficient implementation he called DLX.
The exact cover problem is represented in Algorithm X using a matrix ''A'' consisting of 0s and 1s. The goal is to select a subset of the rows so that the digit 1 appears in each column exactly once.
Algorithm X functions as follows:
:
The nondeterministic choice of ''r'' means that the algorithm essentially clones itself into independent subalgorithms; each subalgorithm inherits the current matrix ''A'', but reduces it with respect to a different row ''r''.
If column ''c'' is entirely zero, there are no subalgorithms and the process terminates unsuccessfully.
The subalgorithms form a search tree in a natural way, with the original problem at the root and with level ''k'' containing each subalgorithm that corresponds to ''k'' chosen rows.
Backtracking is the process of traversing the tree in preorder, depth first.
Any systematic rule for choosing column ''c'' in this procedure will find all solutions, but some rules work much better than others.
To reduce the number of iterations, Knuth suggests that the column choosing algorithm select a column with the lowest number of 1s in it.
==Example==
For example, consider the exact cover problem specified by the universe ''U'' = and the collection of sets \mathcal = , where:
:
* ''A'' = ;
:
* ''B'' = ;
:
* ''C'' = ;
:
* ''D'' = ;
:
* ''E'' = ; and
:
* ''F'' = .
This problem is represented by the matrix:
:
Algorithm X with Knuth's suggested heuristic for selecting columns solves this problem as follows:
Level 0
Step 1—The matrix is not empty, so the algorithm proceeds.
Step 2—The lowest number of 1s in any column is two. Column 1 is the first column with two 1s and thus is selected (deterministically):
:
Step 3—Rows ''A'' and ''B'' each have a 1 in column 1 and thus are selected (nondeterministically).
The algorithm moves to the first branch at level 1…
: Level 1: Select Row ''A''
: Step 4—Row ''A'' is included in the partial solution.
: Step 5—Row ''A'' has a 1 in columns 1, 4, and 7:
::
: Column 1 has a 1 in rows ''A'' and ''B''; column 4 has a 1 in rows ''A'', ''B'', and ''C''; and column 7 has a 1 in rows ''A'', ''C'', ''E'', and ''F''. Thus rows ''A'', ''B'', ''C'', ''E'', and ''F'' are to be removed and columns 1, 4 and 7 are to be removed:
::
: Row ''D'' remains and columns 2, 3, 5, and 6 remain:
::
: Step 1—The matrix is not empty, so the algorithm proceeds.
: Step 2—The lowest number of 1s in any column is zero and column 2 is the first column with zero 1s:
::
: Thus this branch of the algorithm terminates unsuccessfully.
: The algorithm moves to the next branch at level 1…
: Level 1: Select Row ''B''
: Step 4—Row ''B'' is included in the partial solution.
: Row ''B'' has a 1 in columns 1 and 4:
::
: Column 1 has a 1 in rows ''A'' and ''B''; and column 4 has a 1 in rows ''A'', ''B'', and ''C''. Thus rows ''A'', ''B'', and ''C'' are to be removed and columns 1 and 4 are to be removed:
::
: Rows ''D'', ''E'', and ''F'' remain and columns 2, 3, 5, 6, and 7 remain:
::
: Step 1—The matrix is not empty, so the algorithm proceeds.
: Step 2—The lowest number of 1s in any column is one. Column 5 is the first column with one 1 and thus is selected (deterministically):
::
: Step 3—Row ''D'' has a 1 in column 5 and thus is selected (nondeterministically).
: The algorithm moves to the first branch at level 2…
:: Level 2: Select Row ''D''
:: Step 4—Row ''D'' is included in the partial solution.
:: Step 5—Row ''D'' has a 1 in columns 3, 5, and 6:
:::
:: Column 3 has a 1 in rows ''D'' and ''E''; column 5 has a 1 in row ''D''; and column 6 has a 1 in rows ''D'' and ''E''. Thus rows ''D'' and ''E'' are to be removed and columns 3, 5, and 6 are to be removed:
:::
:: Row ''F'' remains and columns 2 and 7 remain:
:::
:: Step 1—The matrix is not empty, so the algorithm proceeds.
:: Step 2—The lowest number of 1s in any column is one. Column 2 is the first column with one 1 and thus is selected (deterministically).
:: Row ''F'' has a 1 in column 2 and thus is selected (nondeterministically).
:: The algorithm moves to the first branch at level 3…
::: Level 3: Select Row ''F''
::: Step 4—Row ''F'' is included in the partial solution.
::: Row ''F'' has a 1 in columns 2 and 7:
::::
::: Column 2 has a 1 in row ''F''; and column 7 has a 1 in row ''F''. Thus row ''F'' is to be removed and columns 2 and 7 are to be removed:
::::
::: Step 1—The matrix is empty, thus this branch of the algorithm terminates successfully.
::: As rows ''B'', ''D'', and ''F'' are selected, the final solution is:
::::
::: In other words, the subcollection is an exact cover, since every element is contained in exactly one of the sets ''B'' = , ''D'' = , or ''F'' = .
::: There are no more selected rows at level 3, thus the algorithm moves to the next branch at level 2…
:: There are no more selected rows at level 2, thus the algorithm moves to the next branch at level 1…
: There are no more selected rows at level 1, thus the algorithm moves to the next branch at level 0…
There are no branches at level 0, thus the algorithm terminates.
In summary, the algorithm determines there is only one exact cover: \mathcal^
* = .

抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)
ウィキペディアで「Knuth's Algorithm X」の詳細全文を読む



スポンサード リンク
翻訳と辞書 : 翻訳のためのインターネットリソース

Copyright(C) kotoba.ne.jp 1997-2016. All Rights Reserved.